package com.fruit.account.common;

import java.math.BigDecimal;

import com.fruit.pojo.push.Message;
import com.fruit.pojo.user.sysmsg.SysMessage;
import com.fruit.util.DateUtil;

/**
 * 二级返销相关常量
 * 
 * @author Administrator
 * @version 2017.11.30 11:40
 */
public class CommMsgUtil {
	public static final String TITLE = "邀请奖励";
	public static final String CONTENT = "您于${time}到账${money}元环保奖励，由${phone}提供";
	
	public static final String TITLE2 = "奖励到账";
	public static final String CONTENT2 = "恭喜园主，您于${time}，有一笔${money}元的环保卫士奖励已经到账！";
	
	protected CommMsgUtil() {
		
	}
	
	/**
	 * 构建返销push消息体
	 * @param userId userId
	 * @param money money
	 * @return 消息对象
	 */
	public static Message getPushMsgForComm(String h5Domain, BigDecimal money) {
		Message msg = new Message();
		msg.setTitle(TITLE2);
		msg.setRedirect("04");//04：环保奖励页面。 
		msg.setRedirectType("01"); // 01(redirect)
		msg.setParams("");
		msg.setUrl(h5Domain+"/myInvite");
		String msgBody = CONTENT2;
		msgBody = msgBody.replace("${time}", DateUtil.getChandEngTime()).replace("${money}", String.valueOf(money.setScale(2, BigDecimal.ROUND_HALF_DOWN).doubleValue()));
		msg.setContent(msgBody);		
		return msg;
	}
	/**
	 * 构建返销发送消息体
	 * @param userId userId
	 * @param money money
	 * @return 消息对象
	 */
	public static SysMessage getMsgForComm(String h5Domain,Integer userId, BigDecimal money) {
		SysMessage msg = new SysMessage();
		msg.setUserId(userId);
		msg.setType("03"); // 邀请奖励
		msg.setMsgType("00"); //通知
		msg.setTitle(TITLE2);
		msg.setState("00"); // 未读取
		msg.setCreateTime(DateUtil.getTime());
		msg.setRedirect("04");//04：环保奖励页面。 
		msg.setRedirectType("01"); // 01(redirect)
		msg.setUrl(h5Domain+"/myInvite");
		String msgBody = CONTENT2;
		msgBody = msgBody.replace("${time}", DateUtil.getChandEngTime()).replace("${money}", String.valueOf(money.setScale(2, BigDecimal.ROUND_HALF_DOWN).doubleValue()));
		msg.setContent(msgBody);
		return msg;
	}
	
	/**
	 * 构建返销发送消息体
	 * @param userId userId
	 * @param money money
	 * @param phone phone
	 * @return 消息对象
	 */
	public static SysMessage getMsgForComm(Integer userId, BigDecimal money, String phone) {
		SysMessage msg = new SysMessage();
		msg.setUserId(userId);
		msg.setType("03"); // 邀请奖励
		msg.setMsgType("00"); //通知
		msg.setTitle(TITLE);
		msg.setState("00"); // 未读取
		msg.setCreateTime(DateUtil.getTime());
		String msgBody = CONTENT;
		msgBody = msgBody.replace("${time}", DateUtil.getChinaTime()).replace("${money}", String.valueOf(money.setScale(2, BigDecimal.ROUND_HALF_DOWN).doubleValue()))
				.replace("${phone}", phone);
		msg.setContent(msgBody);
		return msg;
	}
}
